﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using FinalSilverlightProject.Web.Resources;

namespace FinalSilverlightProject.Web.Models
{
    public class EditRegistrationData
    {
        /// <summary>
        /// Gets and sets the user name.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 0, Name = "UserNameLabel", ResourceType = typeof(RegistrationDataResources))]
        [RegularExpression("^[a-zA-Z0-9_]*$", ErrorMessageResourceName = "ValidationErrorInvalidUserName", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [StringLength(255, MinimumLength = 4, ErrorMessageResourceName = "ValidationErrorBadUserNameLength", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        public string UserName { get; set; }

        /// <summary>
        /// Gets and sets the friendly name of the user.
        /// </summary>
        [Display(Order = 1, Name = "FriendlyNameLabel", Description = "FriendlyNameDescription", ResourceType = typeof(RegistrationDataResources))]
        [StringLength(255, MinimumLength = 0, ErrorMessageResourceName = "ValidationErrorBadFriendlyNameLength", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        public string FriendlyName { get; set; }

        /// <summary>
        /// Gets and sets the email address.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 2, Name = "EmailLabel", ResourceType = typeof(RegistrationDataResources))]
        [RegularExpression(@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
                           ErrorMessageResourceName = "ValidationErrorInvalidEmail", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        public string Email { get; set; }


        /// <summary>
        /// Gets and sets the first name of the user.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 5, Name = "FirstNameLabel", ResourceType = typeof(RegistrationDataResources))]
        public string FirstName { get; set; }

        /// <summary>
        /// Gets and sets the last name of the user.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 6, Name = "LastNameLabel", ResourceType = typeof(RegistrationDataResources))]
        public string LastName { get; set; }

        /// <summary>
        /// Gets and sets the street of address.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 7, Name = "StreetAddressLabel", ResourceType = typeof(RegistrationDataResources))]
        public string StreetAddress { get; set; }

        /// <summary>
        /// Gets and sets the city of living.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 8, Name = "CityLabel", ResourceType = typeof(RegistrationDataResources))]
        public string City { get; set; }

        /// <summary>
        /// Gets and sets the country of living.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 9, Name = "CountryLabel", ResourceType = typeof(RegistrationDataResources))]
        public string Country { get; set; }

        /// <summary>
        /// Gets and sets the post code of address.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 10, Name = "PostCodeLabel", ResourceType = typeof(RegistrationDataResources))]
        public string PostCode { get; set; }

        /// <summary>
        /// Gets and sets the telephone number of user.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 11, Name = "TelephoneNumberLabel", ResourceType = typeof(RegistrationDataResources))]
        public string TelephoneNumber { get; set; }

    }
    
    public class AdministratorEditRegistrationData : EditRegistrationData
    {
        /// <summary>
        /// Gets and sets the user name.
        /// </summary>
        [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
        [Display(Order = 0, Name = "UserRoleLabel", ResourceType = typeof(RegistrationDataResources))]
        public string Role { get; set; }
    }
}